<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006-2016 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: 流年 <liu21st@gmail.com>
// +----------------------------------------------------------------------

// 应用公共文件

function get_six_code()
{
    return rand(111111,999999);
}

function encode_password(string $password)
{
    $encodePassword = md5(base64_encode(md5(base64_encode(md5($password)))));
    return $encodePassword;
}

function check_email_code(int $email_code)
{
    $sessionEmailCode = \think\facade\Session::get('email_code');
    return $email_code == $sessionEmailCode ? true : false;
}

function long_dump($data)
{
    echo '<pre/>';
    var_dump($data);
    die();
}

function get_ip_city(string $ip)
{
    $city = config('site_des.read_ip_url').$ip;
    $cityMsg = file_get_contents($city);
    $cityMsg = json_decode($cityMsg,true);
    return $cityMsg['data']['country'].' '.$cityMsg['data']['region'].' '.$cityMsg['data']['city'];
}